package serverController;

import model.hospital.Bed;
import model.hospital.BuildingDB;
import model.hospital.Location;
import model.hospital.Room;
import net.passClass.PassData;
import util.DataInit;
import util.DataStore;

import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;

public class Start {
    public static void main(String[] args) {
        DataInit.initialize();

        Runnable r = new ServerThread();
        Thread t0 = new Thread(r);
        t0.start();

//        doSth();

        Scanner scanner = new Scanner(System.in);
        while(!scanner.next().equals("e"));//server_shutdown

        DataStore.store();
    }

    public static void doSth(){

        Random r = new Random();

        TreeSet<Bed> beds = new TreeSet<>();
        beds.add(
                new Bed(r.nextInt(4),
                        String.valueOf(r.nextInt(30)),
                        String.valueOf(r.nextInt(30)),
                        String.valueOf(r.nextInt(30)))
        );

        PassData str = BuildingDB.getInstance().add(
                new Room(String.valueOf(r.nextInt(30)),
                        new Location(
                                r.nextInt(4),
                                r.nextInt(10),
                                r.nextInt(30)
                        ),
                        "普通",
                        "无",
                        null,
                        beds
                )
        );
        System.out.println(str.getMessage());
    }
}
